package cn.com.asd.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.com.asd.service.TbSpuService;
import cn.netshop.pojo..TbSpu;

/**
 * TbSpu的路由接口服务
 * 
 * @author 
 *
 */
@RestController
public class TbSpuController {

	/** TbSpuService服务 */
	@Autowired
	private TbSpuService tbSpuService;
	
	/**
	 * 查询所有TbSpu数据的方法
	 * @param value
	 * @return
	 */
	@GetMapping(value = "/TbSpu", produces = {"application/json;charset=UTF-8"})
	public String find(TbSpu value) {
		return tbSpuService.find(value);
	}
	
	/**
	 * 通过id查询TbSpu数据的方法
	 * @param id
	 * @return
	 */
	@GetMapping(value = "/TbSpu/{id}", produces = {"application/json;charset=UTF-8"})
	public String findOne(@PathVariable(name="id") String id) {
		return tbSpuService.findOne(id);
	}
	
	/**
	 * 插入TbSpu属性不为空的数据方法
	 * @param id
	 * @return
	 */
	@PostMapping(value = "/TbSpu", produces = {"application/json;charset=UTF-8"})
	public String save(TbSpu value) {
		return tbSpuService.saveNotNull(value);
	}
	
	/**
	 * 更新TbSpu属性不为空的数据方法
	 * @param id
	 * @return
	 */
	@PutMapping(value = "/TbSpu", produces = {"application/json;charset=UTF-8"})
	public String update(TbSpu value) {
		return tbSpuService.updateNotNullById(value);
	}

	/**
	 * 通过id删除TbSpu数据方法
	 * @param id
	 * @return
	 */
	@DeleteMapping(value = "/TbSpu/{id}", produces = {"application/json;charset=UTF-8"})
	public String delete(@PathVariable(name="id") String id) {
		return tbSpuService.deleteById(id);
	}
}
